package com.nbufe.command.demo2;

/**
 * @Author Zan
 * @Create 2024/6/12 14:09
 * @ClassName: ConcreteCommand
 * @Description : TODO 请用一句话描述该类的功能
 */
public class ConcreteCommand extends AbstractCommand {

    private Adder adder = new Adder();

    private Subtractor subtractor = new Subtractor();

    private int value;

    @Override
    public int execute(int value) {
        this.value = value;
//        return adder.add(value);
        return subtractor.sub(value);
    }

    @Override
    public int undo() {
//        return adder.add(-value);
        return subtractor.sub(-value);
    }

    @Override
    public int redo() {
//        return adder.add(value);
        return subtractor.sub(value);
    }
}
